package com.jsnj33.pdaproject.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.jsnj33.pdaproject.R;
import com.jsnj33.pdaproject.bean.ChangeBean;
import com.jsnj33.pdaproject.bean.FormGoodsBean;

import java.util.List;

public class ChangeListAdapter extends RecyclerView.Adapter<ChangeListAdapter.ViewHolder> {

    private Context mContext;
    private List<ChangeBean> list;

    public ChangeListAdapter(Context context) {
        this.mContext = context;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_item_changelist, parent, false);
        ViewHolder viewHolder = new ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {

        ChangeBean tfBean = list.get(position);
        holder.tv_number.setText(tfBean.getStock() + "");
        holder.tv_ord_no.setText(tfBean.getPrdNo());
        holder.tv_name.setText(tfBean.getName());
        holder.tv_bat_no.setText(tfBean.getBatNo());
        holder.tv_wh.setText(tfBean.getWh());

    }

    @Override
    public int getItemCount() {
        return list != null ? list.size() : 0;
    }

    public void setList(List<ChangeBean> list) {
        this.list = list;
        notifyDataSetChanged();
    }

    class ViewHolder extends RecyclerView.ViewHolder {

        private TextView tv_ord_no;//品号
        private TextView tv_name;//品名
        private TextView tv_wh;//库位
        private TextView tv_number;//入库数量
        private TextView tv_bat_no;//批号

        ViewHolder(View itemView) {
            super(itemView);
            tv_ord_no = itemView.findViewById(R.id.tv_ord_no);
            tv_name = itemView.findViewById(R.id.tv_name);
            tv_bat_no = itemView.findViewById(R.id.tv_bat_no);
            tv_number = itemView.findViewById(R.id.tv_number);
            tv_wh = itemView.findViewById(R.id.tv_wh);
        }
    }
}
